Vector is base class of other vector like classes. It represents a series of vectors.
from py3d import Vector
Vector()
Vector([], dtype=float64)
Vector([0, 0, 0, 0])
Vector([0, 0, 0, 0])
Vector([1, 2, -4])
Vector([ 1, 2, -4])
Vector([1, 2, 3], (2,))
Vector([[1, 2, 3],
[1, 2, 3]])
import py3d
py3d.Vector([1, 2, 0, 3], ())
Vector([1, 2, 0, 3])
Vector([1], (2,))
Vector([[1],
[1]])
V32 = Vector([
[1, 3],
[2, -9],
[0.1, -3]])
V32
Vector([[ 1. , 3. ],
[ 2. , -9. ],
[ 0.1, -3. ]])
Get unit vector
V32.U
Vector([[ 0.31622777, 0.9486833 ],
[ 0.21693046, -0.97618706],
[ 0.03331483, -0.99944491]])
Get length of vectors
V32.L
array([[3.16227766],
[9.21954446],
[3.0016662 ]])
from numpy import allclose
assert allclose(V32.U.L, [[1], [1], [1]])
Get homogeneous vector
V32.H
Vector([[ 1. , 3. , 1. ],
[ 2. , -9. , 1. ],
[ 0.1, -3. , 1. ]])
Get a series of random vectors
import py3d
py3d.Vector.Rand(2,3,4)
Vector([[[0.06454536, 0.18257607, 0.46880573, 0.94302795],
[0.31268705, 0.46440515, 0.08619891, 0.19026944],
[0.49617668, 0.42962972, 0.17365193, 0.85129371]],
[[0.86126597, 0.82859757, 0.02224853, 0.29172221],
[0.73438044, 0.88289172, 0.00850015, 0.29887647],
[0.19334198, 0.58236154, 0.89621615, 0.54093803]]])
import py3d
py3d.Vector([[0,0],[1,2],[3,4]]).diff()
Vector([[1, 2],
[2, 2]])
Read pcd file
import py3d
py3d.read_pcd("py3d/doc/ascii.pcd").xyz.as_point()
import py3d
pcd = py3d.read_pcd("py3d/doc/binary.pcd")
pcd.xyz.as_point()
pcd.to_pcd("test.pcd")